﻿#include "IM_Server.h"
#include "Base_MessageCore.h"
#include "IM_Socket_Server.h"
#include "Base_Context.h"
#include "IM_Gate.h"
#include "IM_Account.h"
#include <string>
#include <vector>
#include "IM_VirtualData.h"


IM_Server::IM_Server()
{
}


IM_Server::~IM_Server()
{

}


bool IM_Server::init(const Config & conf)
{
	//加载数据库 

	IM_VirtualData::getInstance()->init_data();

	//初始化消息处理核心
	m_base_message_core=Base_MessageCore::get_instance();
	if (m_base_message_core==nullptr||!m_base_message_core->start(conf))
	{
		return false;
	}

	//初始化账户服务 
	m_account_server = IM_AccountServer::getInstance();
	if (m_account_server==nullptr||!m_account_server->init())
	{
		return false;
	}

	//初始化socket server 
	m_socket_server = new IM_Socket_Server();
	if (m_socket_server==nullptr||!m_socket_server->socket_server_start()) 
	{
		return false;
	}

	//初始化网关服务
	m_gate = new IM_Gate();
	if (m_gate==nullptr||!m_gate->init(m_base_message_core, m_socket_server))
	{
		return false;
	}

	
	return true;
}



int IM_Server::run()
{
	while (true)
	{

	}
}
